package com.ccbooks.util;

import android.graphics.Typeface;



public class Font {

         public static final int STYLE_PLAIN = 0;

         public static final int STYLE_BOLD = 1;

         public static final int STYLE_ITALIC = 2;

         public static final int STYLE_UNDERLINED = 4;

         public static final int SIZE_SMALL = 22;

         public static final int SIZE_MEDIUM = 31;

         public static final int SIZE_LARGE = 40;

         public static final int FACE_SYSTEM = 0;

 

         private int face;

         private int style;

         private int size;

         private int baseline;

         

         private int width;

         private int height;

         

         public void setWidth(int width)

         {

                   this.width = size;

         }

         

         public void setHeight(int height)

         {

                   this.height = height;

         }

         

         public int getWidth()

         {

                   return size;

         }

         

         public int getHeight()

         {

                   return height;

         }

         

         private Typeface iTypeface = Typeface.DEFAULT;

         

         public Typeface getTypeface()

         {

                   return iTypeface;

         }

         

         public void setSize(int fontSize)

         {

                   size = fontSize;

         }

         

         public int getSize()

         {

                   return size;

         }

 

         private static final Font DEFAULT_FONT = new Font(null,22);

         

         public Font(Typeface aTypeface,int aSize)

         {

                   if(iTypeface != null)

                            iTypeface = aTypeface;

                   size = aSize;

         }

 

         public static Font getFont(int fontSepcifier)

         {

                   switch(fontSepcifier)

                   {

                   case SIZE_SMALL:

                            return new Font(null,22);

                   case SIZE_MEDIUM:

                            return new Font(null,31);

                   case SIZE_LARGE:

                            return new Font(null,40);

                   }

                   

                   return DEFAULT_FONT;

         }

 

         public static Font getDefaultFont()

         {

                   return DEFAULT_FONT;

         }

 

         public static Font getFont(int face,int style,int size)

         {

                   switch(style)

                   {

                   case STYLE_PLAIN:

                            return new Font(Typeface.defaultFromStyle(Typeface.NORMAL),size);

                   case STYLE_BOLD:

                            return new Font(Typeface.defaultFromStyle(Typeface.BOLD),size);

                   case STYLE_ITALIC:

                            return new Font(Typeface.defaultFromStyle(Typeface.ITALIC),size);

                   }

                   

                   return DEFAULT_FONT;

         }

 

         public int charWidth(char arg)

         {

                   return size;

         }

 

         public int stringWidth(String arg)

         {

                   return size*(arg.length());

         }

}

